package org.dromara.learning_lhz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.learning_lhz.entity.AsLearningTasksEntity;
import org.dromara.learning_lhz.entity.dto.AsLearningTasksDto;
import org.dromara.learning_lhz.entity.vo.TaskVo;
import org.dromara.learning_lhz.service.LearningTasksService;
import org.springframework.web.bind.annotation.*;

/**
 * 学习任务控制器
 * 负责处理与学习任务相关的HTTP请求
 */
@RestController
@RequestMapping("learningTasks")
public class LearningTasksController {

    @Resource
    private LearningTasksService learningTasksService;

    /**
     * 查询学习任务
     *
     * @param pageQuery          分页查询参数
     * @param asLearningTasksDto 查询条件
     * @return 学习任务列表
     **/
    @GetMapping("selTask")
    public Page<TaskVo> selTask(PageQuery pageQuery, AsLearningTasksDto asLearningTasksDto) {
        return learningTasksService.selTask(pageQuery, asLearningTasksDto);
    }

    /**
     * 添加学习任务
     **/
    @PostMapping("addTask")
    public void addTask(@RequestBody AsLearningTasksDto asLearningTasksDto) {
        learningTasksService.addTask(asLearningTasksDto);
    }

    /**
     * 更新学习任务
     **/
    @PostMapping("updateTask")
    public void updateTask(@RequestBody AsLearningTasksEntity asLearningTasksEntity) {
        learningTasksService.updateById(asLearningTasksEntity);
    }

    /**
     * 删除学习任务
     **/
    @PostMapping("deleteTask")
    public void deleteTask(@RequestBody AsLearningTasksEntity asLearningTasksEntity) {
        learningTasksService.removeById(asLearningTasksEntity);
    }

}
